﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Masood.Utilities.EmailTemplates.Items;

namespace Masood.Utilities.EmailTemplates.Manager
{
    public class TestTemplateManager : AbstractTemplateManager
    {
        public TestTemplateManager()
        {
        }

        public override Items.EmailTemplate GetTemplate(string templateId)
        {
            //just for testing purpose
            EmailTemplate emailTemplate = new EmailTemplate();
            emailTemplate.Subject = "This is test email on [CURRENT_DATE]";
            emailTemplate.Body = @"Hi [CUSTOMER]<br/> We have delivered your order on [DELIVERY_DATE]<br/>Regards<br/>[REGARDS]";

            return emailTemplate;
        }

        public override void BeforeApplyingTemplateOnSubject(Items.EmailTemplate template, ref Items.Email email, Items.IItem anItem)
        {
            
        }

        public override void AfterApplyingTemplateOnSubject(Items.EmailTemplate template, ref Items.Email email, Items.IItem anItem)
        {
            email.Subject = email.Subject.Replace("[CURRENT_DATE]", DateTime.Now.ToString());
        }

        public override void BeforeApplyingTemplateOnBody(Items.EmailTemplate template, ref Items.Email email, Items.IItem anItem)
        {
            
        }

        public override void AfterApplyingTemplateOnBody(Items.EmailTemplate template, ref Items.Email email, Items.IItem anItem)
        {
            email.Body = email.Body.Replace("[REGARDS]", "Muhammad Masood");
        }
    }
}
